import request from '../request';


function createWorkOrder(data) {
  return request.ajax('/workOrder', { method: 'post', ...data })
}

function listWorkOrder(data) {
  return request.ajax('/workOrder', { ...data })
}

function getWorkOrderById(id) {
  return request.ajax(`/workOrder/${id}`)
}

function createAppointment(id) {
  return request.ajax(`/training/course/${id}/appointment`, { method: 'post' })
}

function getCourseAppointment() {
  return request.ajax('/training/appointment')
}

/**
 * 更新工单
 */
function updateWorkOrder(id, data) {
  return request.ajax(`/workOrder/${id}/submit`, {
    method: 'post',
    ...data
  })
}

function createEntrustment(data) {
  return request.ajax(`/entrustment`, { method: 'post', ...data })
}

const workOrder = {
  createWorkOrder, listWorkOrder, getWorkOrderById, createAppointment, getCourseAppointment, updateWorkOrder, createEntrustment
};

export default workOrder;